<?php defined('IN_NWIDC') or exit('Access Invalid!');?>

<script src='/data/resource/layer/layer.js'></script>

<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <h3>微信接口设置</h3>
      <ul class="tab-base">
        <li><a href="index.php?act=wechat" ><span>自定义菜单</span></a></li>
        <li><a href="index.php?act=wechat&op=reply" ><span>回复设置</span></a></li>
        <li><a href="javascript:;" class="current"><span>接口设置</span></a></li>
      </ul>
    </div>
  </div>
  <div class="fixed-empty"></div>

  <table class="table tb-type2" id="prompt">
    <tbody>
      <tr class="space odd">
        <th colspan="12"><div class="title">
            <h5><?php echo $lang['nc_prompts'];?></h5>
            <span class="arrow"></span></div></th>
      </tr>
      <tr>
        <td><ul>
            <li>
              在微信的服务器配置中填入如下信息：
            </li>
            <li>
              URL : http://<?php echo $_SERVER['HTTP_HOST']?>/shop/?act=wechat
            </li>
            <li>
              TOKEN : yhg_weixin_token
            </li>
          </ul></td>
      </tr>
    </tbody>
  </table>   
  <?php

    $config = Model('wechat_config')->where(array('member_id' => -1))->find();
    if($config){
      $config = json_decode($config['config'],true);
    }
    else{
      $config = array();
    }

    if(count($_POST)){
     ?>
     <script>
     layer.msg('保存成功',{icon:1});
     </script>
     <?php 
    }
  ?>
  <form method="post" id='form_list' action="index.php?act=wechat&op=config">

    <table class="table tb-type2">
      
      <tbody>
        <tr class="hover">
          <td width='15%'>公众账号ID (appid)</td>
          <td><input type='text' name='appid' class='w200' value='<?php echo $config[appid]?>'/></td>
        </tr>
        <tr>
          <td width='15%'>商户号(mch_id)</td>
          <td><input type='text' name='mch_id' class='w200' value='<?php echo $config[mch_id]?>'/></td>
        </tr>
        <tr>
          <td width='15%'>商户支付密钥(key)</td>
          <td>
            <input type='text' name='key' class='w200' value='<?php echo $config[key]?>'/>
          </td>
        </tr>
        <tr>
          <td width='15%'>
            公众账号secert(appsecret)
          </td>
          <td>
            <input type='text' name='appsecret' class='w200'value='<?php echo $config[appsecret]?>'/>
          </td>
        </tr>
        <tr>
          <td width='15%'>
            微信号（原始ID）
          </td>
          <td>
            <input type="text" name='source_id' class='w200' value='<?php echo $config[source_id]?>'>
          </td>
        </tr>
        <tr>
          <td width='15%'>
            开放平台appid
          </td>
          <td>
            <input type="text" name='open_appid' class='w200' value='<?php echo $config[open_appid]?>'>
          </td>
        </tr>
        <tr>
          <td width='15%'>
            开放平台AppSecret
          </td>
          <td>
            <input type="text" name='open_appsecret' class='w200' value='<?php echo $config[open_appsecret]?>'>
          </td>
        </tr>
        <tr>
          <td colspan="20">
            <a href="javascript:;" class="btn" onclick='$("form").submit()'>保存设置</a>
          </td>
        </tr>
      </tbody>

    </table>
  </form>
</div>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/jquery-ui/jquery.ui.js"></script> 
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/jquery-ui/i18n/zh-CN.js" charset="utf-8"></script>
<link rel="stylesheet" type="text/css" href="<?php echo RESOURCE_SITE_URL;?>/js/jquery-ui/themes/ui-lightness/jquery.ui.css"  />
<script type="text/javascript">
$(function(){
    $('#time_from').datepicker({dateFormat: 'yy-mm-dd'});
    $('#time_to').datepicker({dateFormat: 'yy-mm-dd'});
    $('#ncexport').click(function(){
    	$('input[name="op"]').val('export_step1');
    	$('#formSearch').submit();
    });
    $('#ncsubmit').click(function(){
    	$('input[name="op"]').val('list');
    	$('#formSearch').submit();
    });
    $('#ncdelete').click(function(){
        $('#delago').val($('#delago1').val());
    	$('input[name="op"]').val('list_del');$('#formSearch').submit();
    });
});
</script>
